#pragma once

#include <string>
#include <memory>
#include <vector>
#include <ostream>
#include <boost/asio.hpp>


namespace frame {
namespace imp {

class WriteBuffer;

} //end of namespace imp
} //end of namespace  frame


namespace frame {
namespace imp {
namespace asio {

class AsioWriteBuffer {
public:
    AsioWriteBuffer();
    ~AsioWriteBuffer();
    void pushBack(const std::string & str);
    void pushBack(std::string && str);
    void pushBack(const char * cstr);
    void pushBack(const char * buf, size_t len);
    void popBack();
    /*  
    const std::string & front() const{
        return wb->front();
    }
    const std::string & back() const{
        return wb->back();
    }*/
    void clear();
    size_t size() const;

    //for ConstBuffer concept
    typedef boost::asio::const_buffer value_type;
    typedef std::vector<boost::asio::const_buffer>::const_iterator const_iterator;
    const_iterator begin() const { return buffers.cbegin(); }
    const_iterator end() const { return buffers.cend();}

private:
    std::shared_ptr<WriteBuffer>  wb;
    std::vector<boost::asio::const_buffer> buffers;
};

std::ostream & operator<<(std::ostream & os, const AsioWriteBuffer & awb);

} //end of namespace asio
} //end of namespace imp
} //end of namespace  frame
